//////////////////////////////////////////////////////////////////////////
// by George Ulyanov
// (c) 2010
//////////////////////////////////////////////////////////////////////////

// Loggr::Loggr
// Simple lightweight cross-platform logger.

#ifndef LOGGR_LOGGR_H_
#define LOGGR_LOGGR_H_

namespace Loggr
{
    struct LoggrData;   /** Pre-declaration. */

    /**
    *   @brief Loggr
    */
    class Loggr
    {
    public:
        const size_t    m_maxBytesPerAdd;
        const size_t    m_maxBuffersSize;

    private:
        char*           m_buffer1;
        char*           m_buffer2;
        char*           m_currBuffer;
        size_t          m_offset;
        bool            m_needFlush;
        bool            m_stopFlusher;

        LoggrData*      m_data;

    public:
        /**
        *   @brief A default constructor.
        */
        Loggr();

        /**
        *   @brief Destructor.
        */
        ~Loggr() throw();

        /**
        *   @brief Flush collected data.
        */
        void ForceXchange();

        /**
        *   @brief Add a data portion for logging.
        *   @param pStr - formatted string to be added.
        *   @param ... - arguments list.
        */
        void Write(const char* pStr, ...);

    private:
        /**
        *   @brief Flushing thread function.
        */
        static int BuffersXchange(void* p);
    };
}
// namespace Loggr

#endif LOGGR_LOGGR_H_
